package com.cat.greedyAlgorithm;

import java.util.Arrays;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/check-if-a-string-can-break-another-string/
 * @create 2025/8/23 10:40
 * @since JDK17
 */

public class Solution22 {
    public boolean f(char[] s1, char[] s2) {
        int n = s1.length;
        for (int i = 0; i < n; i++) {
            if (s1[i] > s2[i]) {
                return false;
            }
        }

        return true;
    }
    public boolean checkIfCanBreak(String str1, String str2) {
        char[] s1 = str1.toCharArray(), s2 = str2.toCharArray();
        Arrays.sort(s1);
        Arrays.sort(s2);
        return f(s1, s2) || f(s2, s1);
    }
}
